<div class="content_box">
  <h1><?php echo $BolaoTournament->getName()." (".$BolaoTournament->getBolaoSubcategory().')' ?></h1>
  <div class="right_corner">
  <?php if ($sf_user->isSuperAdmin()): ?>
    <a class="contentbox_btn" href="<?php echo url_for('tournament_edit', $BolaoTournament) ?>">Editar</a>
  <?php endif; ?>
  </div>
  <div class="content">

    <h3>Equipes participantes</h3>

      <ul>
    <?php foreach ($teams as $team): ?>
        <li><?php echo $team['name'] ?></li>
    <?php endforeach; ?>
      </ul>

    <h3>Jogos</h3>

    <?php
      if (count($phases) == 1)
      {
        include_partial('tournament/listgames', array(
          'championship' => $championship,
          'games' => $games,
          'teams' => $teams,
          'players' => $players,
        ));
      }
      else
      {
        echo "<p>TODO: implement multi-phase game list</p>";
      }
    ?>

    <h3>Classifica&ccedil;&atilde;o Geral</h3>

    <?php
      if ($championship['type'] == 'TEAMS')
      {
        if (count($phases) == 1)
        {
          $phase = current($phases);

          if (count($phase['groups']) == 1)
          {
            if ($phase['game_type'] == 'ALL_PLAY' && 
                $phase['ca']['type'] == 'ClassifyByPoints')
              include_partial('tournament/classifybypoints', array(
                'teams'   => $teams,
                'players' => $players,
                'games'   => $games,
                'points'  => $phase['ca']['points'],
              ));
            else
            {
              echo "<p>TODO: implement other classification algorithms</p>";
            }
          }
          else
          {
            echo "<p>TODO: implement multi-group layout</p>";
          }
        }
        else
        {
          echo "<p>TODO: implement multi-phase layout</p>";
        }
      }
      else  // $championship['type'] != 'TEAMS'
      {
        if (count($modalities) > 0)
        {
          echo '<div class="accordion">';
          foreach($modalities as $modality)
          {
            echo '<h3><a href="#">'.$modality['name'].'</a></h3>';
            echo '<div>';
            include_partial('tournament/classifyModalityByTotal', array(
                'teams'   => $teams,
                'players' => $players,
                'games'   => $games,
                'modality'=> $modality,
              ));
            echo '</div>';
          }
          echo '</div>';
        }
      }
    ?>

    <h3>Classifica&ccedil;&atilde;o Individual</h3>

    <?php
      if ($championship['team']['modality'] != 'MIXED')
      {
        include_partial('tournament/classifyplayers', array(
          'teams'   => $teams,
          'players' => $players,
          'games'   => $games,
          'modality'=> $championship['team']['modality'],
        ));
      }
      else
      {
        echo '<div class="accordion">';
        echo '  <h3><a href="#">Masculino</a></h3>';
        echo '  <div>';
        include_partial('tournament/classifyplayers', array(
          'teams'   => $teams,
          'players' => $players,
          'games'   => $games,
          'modality'=> 'MASCULINE',
        ));
        echo '  </div>';

        echo '  <h3><a href="#">Feminino</a></h3>';
        echo '  <div>';
        include_partial('tournament/classifyplayers', array(
          'teams'   => $teams,
          'players' => $players,
          'games'   => $games,
          'modality'=> 'FEMININE',
        ));
        echo '  </div>';
        echo '</div>';
      }
    ?>

  </div>
</div>
